package com.example4.test1;

/**
 * @Auther: shiquan
 * @Date: 2024/10/15 - 10 - 15 -16:44
 */
public class GameTest {
    public static void main(String[] args) {
        Role r1 = new Role("乔峰", 100);
        //创建第二个角色
        Role r2 = new Role("驱魔者",100);
        //3开始格斗
        while (true){
            //r1开始打r2
            r1.attack(r2);
            //判断r2剩余血量
            if (r2.getBlood()==0){
                System.out.println(r1.getName()+"KO"+r2.getName());
                break;
            }

            //r2开始攻击r1
            r2.attack(r1);
            if (r1.getBlood()==0) {
                System.out.println(r2.getName() + "KO" + r1.getName());
                break;
            }
        }
    }
}
